home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / turboc.doc < prev    next >
Text File  |  1995-03-31  |  13KB  |  271 lines

  1. Mark G. Forbes, Sparcom Corp.                     (forbesm@jacobs.cs.orst.edu)
  2. work 503-757-8416 (where I spend all my time)     (or, support@sparcom.com)
  3. home     754-3104 (where the hedges grow ever larger)
  4. Disclaimer: "WE are the people our parents warned us about!"
  5. Path: irisa!corton!mcsun!news.funet.fi!sunic!psinntp!psinntp!uunet!ogicse!hp-cv!hp-pcd!hpcvra.cv.hp.com!andyg
  6. From: andyg@hpcvra.cv.hp.com. (Andrew Gryc)
  7. Newsgroups: comp.sys.palmtops
  8. Subject: Using Turbo C to create HP95LX EXM files
  9. Message-ID: <65300031@hpcvra.cv.hp.com.>
  10. Date: 9 Oct 91 19:58:56 GMT
  11. Organization: Hewlett-Packard Co., Corvallis, OR, USA
  12. Lines: 110
  13.  
  14. ***********************************************************************
  15. Using Borland C to create .EXM files for the HP95LX
  16. ***********************************************************************
  17.  
  18. Yes, believe it or not, you can use Borland tools to create System
  19. Manager compliant applications for the 95LX!  Although this has been
  20. tested only with Turbo C++ and Borland C++, it should work for the whole
  21. Turbo C family.  The two basic problems to work around are the startup
  22. code and the E2M program.
  23.  
  24. (NOTE: TKERNEL is a PC TSR that provides the SysMgr services on the PC,
  25.   in a non-task-swapping environment, allowing you to debug your program
  26.   on a PC, using standard PC debuggers.  Unfortunately, this program is
  27.   property of Lotus Corporation, which as decided NOT to allow its
  28.   distribution to anyone EXCEPT for ISV's that have been accepted into
  29.   the supported ISV program.  However, the rest of this note (regarding
  30.   creating .EXM files for use on the HP 95LX, is applicable even if you
  31.   DON'T have access to TKERNEL.)
  32.  
  33. To create programs to run under TKERNEL, you shouldn't need to do
  34. anything special.  Just make sure to link in CSVC.OBJ (included in the
  35. ISV kit and on the HP BBS) so the c_service routines are defined.  Since
  36. you will probably want to use the Turbo C integrated environment, MAKE
  37. SURE YOU INCLUDE any #defines that the Microsoft make file may jam in
  38. before you compile.  BOXES.C is an example of this: it defines TKERNEL
  39. from the make file for the tkernel file, but does not for the EXM file.
  40. If you run non-TKERNEL code under TKERNEL you will almost certainly have
  41. problems (eg. Divide overflow) since TKERNEL doesn't support the full
  42. set of System Manager functions.
  43.  
  44. STEP 1
  45. ------
  46. To create .EXM programs for the System Manager, it gets a little more
  47. complicated.  First of all, you need to trick Turbo C into leaving out
  48. its own startup code and including CRT0.OBJ (also included in the ISV
  49. kit / HP BBS).    CRT0 is just about the minimum that is needed upon
  50. startup so the program doesn't do all kinds of funny stuff on the 95
  51. that isn't supported.  To do this, go to the directory that you keep
  52. your CRT0.OBJ and CSVC.OBJ files (assume it is \HP95\TOOLS) , and copy
  53. CRT0.OBJ into a new file, C0S.OBJ.    C0S.OBJ is the file that Turbo C
  54. uses for small model startup code, so we're just replacing it.
  55.  
  56. Now go into the integrated environment under Options/Directory/Libraries,
  57. and insert the directory name \HP95\TOOLS; (or whatever you use) *in
  58. front* of what currently lies there (so it will find our "fake" C0S
  59. first). Also remember to link in CSVC.OBJ as well (just add it to your
  60. project file). Now you should be able to compile your SysMgr app with no
  61. problems. (Other helpful hints on compiling:  Remember under small model
  62. code only, no floating point code, and don't link in the graphics
  63. library.)
  64.  
  65. STEP 2
  66. ------
  67. Step 1 will get you a .EXE, but you still need to run E2M to
  68. produce the .EXM file that will end up in the 95LX.  The E2M program
  69. relies on the .MAP file to deduce the data/code segment dividing point.
  70. If you don't already have it set, go into Options/Linker/Mapfile, and
  71. set it to Segments (if you have more map info in the file, that's okay,
  72. but Segments is needed at least).
  73.  
  74. Unfortunately for us, the output of Turbo Map files is not exactly
  75. compatible with the Microsoft format, so either you need to 1) Use the
  76. old E2M and massage the format to what is needed, or 2) write a small
  77. program that will do the massaging for you.
  78.  
  79. Here's how to do it manually:  load the .MAP file into the text editor
  80. of your choice.  Right below the Segment list, you need to insert a couple of
  81. lines of text that will give the DGROUP orgin (ie. beginning of all the data).
  82. The text must be exact--even spaces count.    Type in this:
  83.  Orgin   Group
  84.  xxxx:0  DGROUP
  85. where xxxx is the first four digits in the Start column of the Segment
  86. titled _DATA.  As an example, this is the .MAP file produces for BOXES,
  87. after we have modified it.
  88. ----------------------------
  89.  
  90.  Start  Stop   Length Name               Class
  91.  
  92.  00000H 01D70H 01D71H _TEXT              CODE
  93.  01D80H 024D1H 00752H _DATA              DATA
  94.  024E0H 02CDFH 00800H STACK              STACK
  95.  02CE0H 033E9H 0070AH _BSS               BSS
  96.  
  97.  Origin   Group
  98.  01D8:0   DGROUP
  99.  
  100. ----------------------------
  101. We looked up the segment named _DATA, and took the 01D8 (segment value)
  102. to put in this new information.  With this small modification to the .MAP
  103. file, the E2M program will convert your Turbo C .EXE without a snag.
  104. In theory, it shouldn't be too hard to whip up a program that adds this
  105. little bit of tag information to your map file, and just remember to run
  106. this before you run E2M.  Since the rest of the file beyond the "Origin"
  107. stuff isn't used by E2M, and since the segment info is not likely to change
  108. for a SysMgr app, you could cheat.  Your massager program could seek to
  109. the right position in the .MAP file to read out the segment (01D8), and
  110. seek past it to write this new little block (although it wouldn't be
  111. that much more work to read through the file and do a little parsing to
  112. find the _DATA line).
  113.  
  114. I would strongly suggest trying this out on a program that you know runs
  115. properly under the System Manager first before you start trying untested
  116. programs under TKERNEL or the 95LX.
  117.  
  118. For those of us who would much rather use Borland tools (present company
  119. included), this fix ought to make System Manager programming a little more
  120. palatable.
  121.  
  122.  
  123. --Andy Gryc
  124. Path: irisa!corton!mcsun!news.funet.fi!sunic!psinntp!psinntp!uunet!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!gatech!ncar!csn!copper!aspen.craycos.com!ewv
  125. From: ewv@craycos.com (Eric Varsanyi)
  126. Newsgroups: comp.sys.palmtops
  127. Subject: Re: Using Turbo C to create HP95LX EXM files
  128. Message-ID: <1991Oct10.202707.16443@craycos.com>
  129. Date: 10 Oct 91 20:27:07 GMT
  130. References: <65300031@hpcvra.cv.hp.com.>
  131. Organization: Cray Computer Corporation
  132. Lines: 40
  133.  
  134. In article <65300031@hpcvra.cv.hp.com.> andyg@hpcvra.cv.hp.com. (Andrew Gryc) writes:
  135. >Yes, believe it or not, you can use Borland tools to create System
  136. >Manager compliant applications for the 95LX!  Although this has been
  137. >tested only with Turbo C++ and Borland C++, it should work for the whole
  138. >Turbo C family.  The two basic problems to work around are the startup
  139. >code and the E2M program.
  140.  
  141. Yes, you can use regular turbo C to create stuff for the HP95LX, there
  142. is a trick not mentioned by the author however... The Borland libraries use
  143. some externals that Borland stuck int c0s.asm.  If you link and get
  144. errors with unresolved refs that have 'Vector' in them, it is safe
  145. defining 'long' variables somewhere to satisfy these references.
  146.  
  147. >(NOTE: TKERNEL is a PC TSR that provides the SysMgr services on the PC,
  148. >  in a non-task-swapping environment, allowing you to debug your program
  149. >  on a PC, using standard PC debuggers.
  150.  
  151. Has anyone ever gotten TKERNEL to work with a monochrome adapter? It
  152. works OK for me (I can type at it and it seems to be doing stuff) but
  153. the display is always blank. Is it writing to the CGA memory?
  154.  
  155. >To create .EXM programs for the System Manager, it gets a little more
  156. >complicated.  First of all, you need to trick Turbo C into leaving out
  157. >its own startup code and including CRT0.OBJ (also included in the ISV
  158. >kit / HP BBS).
  159.  
  160. This isn't much of a trick if you just use regular makefiles and the
  161. command line version of tcc and tlink/link.
  162.  
  163. >Unfortunately for us, the output of Turbo Map files is not exactly
  164. >compatible with the Microsoft format, so either you need to 1) Use the
  165. >old E2M and massage the format to what is needed, or 2) write a small
  166. >program that will do the massaging for you.
  167.  
  168. E2M does very little to the .EXE file (only seems to change a couple
  169. of words). If someone can describe what it does I would be happy to
  170. write and post a version that will eat TLINK map files. I have this
  171. same problem and just use the Microsoft linker instead.
  172.  
  173. -Eric Varsanyi    Cray Computer Corporation    ewv@craycos.com
  174. Path: irisa!corton!mcsun!uunet!cs.utexas.edu!wupost!sdd.hp.com!hplabs!hpfcso!hpfcbig!lisa
  175. From: lisa@hpfcbig.SDE.HP.COM (Lisa Stroyan)
  176. Newsgroups: comp.sys.palmtops
  177. Subject: lowest 95lx price and new software
  178. Message-ID: <41730019@hpfcbig.SDE.HP.COM>
  179. Date: 10 Oct 91 14:44:07 GMT
  180. Organization: HP SESD, Fort Collins, CO
  181. Lines: 24
  182.  
  183. I saw the lowest price I have seen so far for a 95lx yesterday.  489.99,
  184. at a new store that just opened in Fort Collins, CO, called "Office
  185. Depot Inc".  This company is a result of a merger between the Florida
  186. based (?) Office Depot and the LA, CA based Office Club, so there may
  187. be one in your area.
  188.  
  189. They also have 95lx accessories, but unfortunately, the discount on
  190. them is much less ($89 for the connectivity pack and *lots* for the
  191. RAM card, I don't remember how much).
  192.  
  193. On another thought, I got an ad for 95lx software in the mail the
  194. other day -- I was so excited to see that companies are finally
  195. starting to sell software!  It was some money management program that
  196. would run both on a PC (full size) and run under the system manager on
  197. the 95lx, so that you could use it either place.  (sorry, I didn't
  198. bring the ad in today, so I don't know the name).  Has anyone tried
  199. this program?  If so, what do you think?  I would love a program like
  200. that for the 95, but I use a different one, Phasar, on an Amiga.  I
  201. would only be willing to switch to using something on my PCs if the
  202. program was really well done, because I like Phasar a lot.
  203.  
  204. Thanks,
  205.  
  206. Lisa
  207. Path: irisa!corton!mcsun!unido!fauern!ira.uka.de!yale.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpfcso!hpfcdc!jsm
  208. From: jsm@hpfcdc.HP.COM (John Marvin)
  209. Newsgroups: comp.sys.palmtops
  210. Subject: Re: Using Turbo C to create HP95LX EXM files
  211. Message-ID: <50840009@hpfcdc.HP.COM>
  212. Date: 12 Oct 91 08:24:23 GMT
  213. References: <65300031@hpcvra.cv.hp.com.>
  214. Organization: HP Fort Collins, Co.
  215. Lines: 53
  216.  
  217.  
  218. I also use Turbo C to create System Manager compliant programs. Since
  219. I have not bought the assembler, I link in the following C module (I call
  220. it tcdummy.c).:
  221.  
  222.     unsigned long __brklvl;
  223.     unsigned long errno;
  224.     unsigned long _envLng;
  225.     unsigned long _envseg;
  226.     unsigned long _envSize;
  227.     unsigned long abort;
  228.     unsigned char *_C0environ[] = { (unsigned char *)0 };
  229.  
  230. I add declarations as I come across other variables that the Turbo C
  231. C-library uses. It would be nice if someone would write a System Manager
  232. version of crt0.s for Turbo C. If someone does write a new crt0.s, might
  233. I suggest that it include the code from csvc.obj? I don't see any reason
  234. for two different .obj files, since the special crt0.obj would only be
  235. used for System Manager compliant applications.
  236.  
  237. As far as the .MAP file is concerned, be aware that you may also have
  238. an initialized data segment preceding the data segment. Here is an
  239. example from one of my programs:
  240.  
  241.  
  242.      Start  Stop   Length Name               Class
  243.  
  244.      00000H 0240FH 02410H _TEXT              CODE
  245.      02410H 02415H 00006H _INIT_             INITDATA
  246.      02418H 02997H 00580H _DATA              DATA
  247.      02998H 02C03H 0026CH _BSS               BSS
  248.      02C08H 03407H 00800H STACK              STACK
  249.  
  250.     Program entry point at 0000:0000
  251.  
  252. A person writing a new E2M program should look for both _INIT_ and _DATA.
  253. Eric Varsanyi volunteered to write a new E2M if someone would tell him
  254. what E2M does. Please note that I do not work at Corvallis and have
  255. only figured this out by doing the same comparison anyone else could do.
  256.  
  257. E2M changes only two 16 bit words in the .EXE file. At offset 0x00 it
  258. changes the EXE magic number from 0x5A4D to 0x4C44. It then puts the
  259. Data segment paragraph address (0x0241 in the above example) at offset
  260. 0x1A (This offset is normally used for the overlay number for a .EXE file).
  261. I think that a new E2M doesn't even need to copy the EXE file.  It could
  262. modify the file in place and then just rename the file (it might be nice
  263. to have an option that does this, instead of copying the file).
  264.  
  265.     John Marvin
  266.     jsm@patchnos.fc.hp.com
  267.  
  268. DISCLAIMER: Although I work for HP, I do not work with the folks in
  269. Corvallis, and I certainly do not speak for HP.
  270.  
  271.